; Project Tea Time.nsi
;
; This script is based on example1.nsi, but it remember the directory, 
; has uninstall support and (optionally) installs start menu shortcuts.
;

;--------------------------------
; The name of the installer
Name "Project Tea Time"

# define name of installer
OutFile "Project Tea Time Setup.exe"

; The default installation directory
InstallDir "$PROGRAMFILES\Project Tea Time"

; Registry key to check for directory (so if you install again, it will 
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\Project Tea Time" "Install_Dir"

; Request application privileges for Windows Vista
RequestExecutionLevel admin

Icon "icon.ico"

;--------------------------------

; Pages

Page components
Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------

; The stuff to install
Section "Project Tea Time (required)"

	SectionIn RO

  ; Put files there
	CreateDirectory "$INSTDIR\sound"
	CreateDirectory "$INSTDIR\graphics"
	SetOutPath "$INSTDIR\sound"
	File "sound\tambourine.wav"
	File "sound\snaredrum.wav"
	File "sound\blipbd.wav"
	File "sound\909ride.wav"
	SetOutPath "$INSTDIR\graphics"
	File "graphics\volume.png"
	File "graphics\trail2.png"
	File "graphics\trail1.png"
	File "graphics\symbols.png"
	File "graphics\sun.png"
	File "graphics\standard.png"
	File "graphics\ratings.png"
	File "graphics\perfect.png"
	File "graphics\numbers2.png"
	File "graphics\numbers_small.png"
	File "graphics\note.png"
	File "graphics\new highscore.png"
	File "graphics\jiku.png"
	File "graphics\great.png"
	File "graphics\failed.png"
	File "graphics\cursor.png"
	File "graphics\ctstart.png"
	File "graphics\ctend.png"
	File "graphics\combo.png"
	File "graphics\charset2_small.png"
	File "graphics\buttons3.png"
	File "graphics\buttons1.png"
	File "graphics\bubble.png"
	File "graphics\bonus mode.png"
	File "graphics\bg.png"
	SetOutPath $INSTDIR
	File "SDL_ffmpeg.dll"
	File "SDL.dll"
	File "readme.txt"
	File "Project Tea Time.exe"
	File "msvcr100.dll"
	File "msvcp100.dll"
	File "config.ini"
	File "avutil-49.dll"
	File "avformat-52.dll"
	File "avcodec-52.dll"
  
  ; Write the installation path into the registry
  WriteRegStr HKLM "SOFTWARE\Project Tea Time" "Install_Dir" "$INSTDIR"
  
  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Project Tea Time" "DisplayName" "Project Tea Time"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Project Tea Time" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Project Tea Time" "NoModify" 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Project Tea Time" "NoRepair" 1
  WriteUninstaller "uninstall.exe"

  ExecShell "open" "$INSTDIR\readme.txt"
  
SectionEnd

; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"

  CreateDirectory "$SMPROGRAMS\Project Tea Time"
  CreateShortCut "$SMPROGRAMS\Project Tea Time\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  CreateShortCut "$SMPROGRAMS\Project Tea Time\Readme.lnk" "$INSTDIR\readme.txt" "" "$INSTDIR\readme.txt" 0
  CreateShortCut "$SMPROGRAMS\Project Tea Time\Config.lnk" "$INSTDIR\Config.ini" "" "$INSTDIR\Config.ini" 0
  CreateShortCut "$SMPROGRAMS\Project Tea Time\Project Tea Time.lnk" "$INSTDIR\Project Tea Time.exe" "" "$INSTDIR\Project Tea Time.exe" 0

SectionEnd

; Optional section (can be disabled by the user)
Section "Desktop Icon"

  CreateShortCut "$DESKTOP\Project Tea Time.lnk" "$INSTDIR\Project Tea Time.exe" "" "$INSTDIR\Project Tea Time.exe" 0

SectionEnd

;--------------------------------

; Uninstaller

Section "Uninstall"
  
  ; Remove registry keys
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Project Tea Time"
  DeleteRegKey HKLM "SOFTWARE\Project Tea Time"

  ; Remove files and uninstaller
	Delete "$INSTDIR\uninstall.exe"
	Delete "$INSTDIR\sound\tambourine.wav"
	Delete "$INSTDIR\sound\snaredrum.wav"
	Delete "$INSTDIR\sound\blipbd.wav"
	Delete "$INSTDIR\sound\909ride.wav"
	Delete "$INSTDIR\graphics\volume.png"
	Delete "$INSTDIR\graphics\trail2.png"
	Delete "$INSTDIR\graphics\trail1.png"
	Delete "$INSTDIR\graphics\symbols.png"
	Delete "$INSTDIR\graphics\sun.png"
	Delete "$INSTDIR\graphics\standard.png"
	Delete "$INSTDIR\graphics\ratings.png"
	Delete "$INSTDIR\graphics\perfect.png"
	Delete "$INSTDIR\graphics\numbers2.png"
	Delete "$INSTDIR\graphics\numbers_small.png"
	Delete "$INSTDIR\graphics\note.png"
	Delete "$INSTDIR\graphics\new highscore.png"
	Delete "$INSTDIR\graphics\jiku.png"
	Delete "$INSTDIR\graphics\great.png"
	Delete "$INSTDIR\graphics\failed.png"
	Delete "$INSTDIR\graphics\cursor.png"
	Delete "$INSTDIR\graphics\ctstart.png"
	Delete "$INSTDIR\graphics\ctend.png"
	Delete "$INSTDIR\graphics\combo.png"
	Delete "$INSTDIR\graphics\charset2_small.png"
	Delete "$INSTDIR\graphics\buttons3.png"
	Delete "$INSTDIR\graphics\buttons1.png"
	Delete "$INSTDIR\graphics\bubble.png"
	Delete "$INSTDIR\graphics\bonus mode.png"
	Delete "$INSTDIR\graphics\bg.png"
	Delete "$INSTDIR\SDL_ffmpeg.dll"
	Delete "$INSTDIR\SDL.dll"
	Delete "$INSTDIR\readme.txt"
	Delete "$INSTDIR\Project Tea Time.exe"
	Delete "$INSTDIR\msvcr100.dll"
	Delete "$INSTDIR\msvcp100.dll"
	Delete "$INSTDIR\log.txt"
	Delete "$INSTDIR\config.ini"
	Delete "$INSTDIR\avutil-49.dll"
	Delete "$INSTDIR\avformat-52.dll"
	Delete "$INSTDIR\avcodec-52.dll"
	RMDir "$INSTDIR\sound"
	RMDir "$INSTDIR\graphics"

  ; Remove shortcuts and  directories
  Delete "$DESKTOP\Project Tea Time.lnk"
  Delete "$SMPROGRAMS\Project Tea Time\*.*"
  RMDir "$SMPROGRAMS\Project Tea Time"
  RMDir "$INSTDIR"

  ; Remove save and config files
  Delete "$PROFILE\save.ptt"
  Delete "$PROFILE\config.ptt"

SectionEnd
